package com.amos.cmp_android.ui;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.TextView;

import com.amos.cmp_android.R;
import com.amos.cmp_android.constant.URLConstant;
import com.facebook.drawee.backends.pipeline.Fresco;
import com.facebook.drawee.view.DraweeView;

/**
 * Created by Amos on 2016/4/22.
 */
public class ShowNewsActivity extends AppCompatActivity {

    private DraweeView draweeView;
    private TextView textView;
    private TextView content;
    private Toolbar toolbar;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Fresco.initialize(ShowNewsActivity.this);
        setContentView(R.layout.activity_show_news);

        textView = (TextView) findViewById(R.id.tv_show_news);
        content = (TextView) findViewById(R.id.tv_show_news_title);
        draweeView = (DraweeView) findViewById(R.id.dv_show_news);
        toolbar = (Toolbar) findViewById(R.id.toolbar);

        toolbar.setTitle("新闻详情");
        setSupportActionBar(toolbar);
        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        Intent intent = getIntent();
        textView.setText(intent.getStringExtra("content"));
        content.setText(intent.getStringExtra("title"));
        draweeView.setController(Fresco.newDraweeControllerBuilder().
                setUri(Uri.parse(URLConstant.HOST + intent.getStringExtra("picUrl"))).
                setAutoPlayAnimations(true).build());
    }
}
